<?php

namespace app\user\controller;

use app\common\respond\HttpApi;
use app\user\logic\FactoryLogic;

class FactoryController
{
    /**
     * @Description 猪厂详情
     * @author: zj
     * @param HttpApi $respond
     * @time 2023/08/29 16:00:39
     * @return null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail(HttpApi $respond)
    {
        $param = [
            'id' => request()->get('id')
        ];
        $rule = [
            'id' => 'require|>:0'
        ];
        validate($rule)->check($param);

        $logic = new FactoryLogic();
        $data = $logic->detail($param['id']);

        return $respond->success($data);
    }

    /**
     * @Description 详情手机端数据展示补充
     * @author: zj
     * @param HttpApi $respond
     * @time 2023/09/19 11:48:26
     * @return null
     */
    public function detailSupply(HttpApi $respond)
    {
        $factoryId = request()->user_info['factory_id'];

        $logic = new FactoryLogic();
        $data = $logic->detailSupply($factoryId);

        return $respond->success($data);
    }

    /**
     * @Description 猪厂的栋、猪栏、猪的统计
     * @author: zj
     * @param HttpApi $respond
     * @time 2023/09/04 16:41:33
     * @return null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function statistic(HttpApi $respond)
    {
        $param = [
            'id' => request()->get('id')
        ];
        $rule = [
            'id' => 'require|>:0'
        ];
        validate($rule)->check($param);

        $logic = new FactoryLogic();
        $data = $logic->statistic($param['id']);

        return $respond->success($data);
    }

}